package com.yungu.swift.api.route.v1.driver.pay.balance;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.api.base.BaseApi;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.constants.CommonConstant;
import com.yungu.swift.constants.OrderConstant;
import com.yungu.swift.order.model.vo.PayVo;
import com.yungu.swift.order.service.PayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author Zerrion
 */
@Controller
@Api(value = "【司机】【支付】【余额】司机余额支付接口", tags = "司机余额支付的相关操作")
public class BalanceApi extends BaseApi {
    @Reference
    private PayService payService;

    @RequestMapping(value = "/api/v1/driver/token/pay/balance/tradeUrl", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    @ApiOperation(value = "余额支付", response = ResponseData.class, notes = "余额支付接口")
    public ResponseData<Map<String, String>> tradeUrl(
            @ApiParam(name = "appid", value = "APP标识", required = true) @RequestParam String appid,
            @ApiParam(name = "orderUuid", value = "订单号", required = true) @RequestParam String orderUuid,
            HttpServletRequest request) {
        return payService.trade(new PayVo(OrderConstant.PAY_PURPOSE_CHARGE_FARE, CommonConstant.DRIVER, OrderConstant.PAY_TYPE_BALANCE,
                getUserUid(request), orderUuid, null, null, appid, null, null));
    }

}
